package carFactory;

import java.util.Vector;

public class Subject implements ISubject{
	private Vector<IObserver> vec = new Vector<IObserver>();
	private String data;
	
	public void setData(String data) {
		this.data = data;
	}

	public String getData() {
		return data;
	}
	
	public void register(IObserver obs) {
		vec.add(obs);
	}
	
	public void unregister(IObserver obs) {
		if(vec.contains(obs)) {
			vec.remove(obs);
		}
	}
	
	public void notifyObservers() {
		for (int i = 0; i < vec.size(); ++i) {
			IObserver obs = vec.get(i);
			obs.refresh(data);
		}
	}
	
}
